local ye__mowang = fk.CreateSkill {
  name = "ye__mowang",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["ye__mowang"] = "殁亡",
  [":ye__mowang"] = "锁定技，当你即将死亡时，若你拥有技能〖党锢〗，则改为休整一轮；然后你减少一点体力上限。",
}

ye__mowang:addEffect(fk.EventPhaseStart, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choice = room:askToChoice(player, {
      choices = {"loseMaxHp"},
      skill_name = ye__mowang.name,
    })
    if choice == "loseMaxHp" then
      room:changeMaxHp(player, -1)
    end
  end,
})

ye__mowang:addEffect(fk.BeforeGameOverJudge, {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(ye__mowang.name, false, true) and
      player:hasSkill("ye__danggu", true, true) and
      player.maxHp > 0
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    player._splayer:setDied(false)
    player.room:setPlayerRest(player, 1)
  end,
})

return ye__mowang
